home *** CD-ROM | disk | FTP | other *** search
/ CD Concept 6 / CD Concept 06.iso / mac / UTILITAIRE / Survival 6.0.2 / Survival Macros < prev   
Encoding:
Text File  |  1995-02-05  |  6.0 KB  |  289 lines  |  [TEXT/MJUA]

  1. {This macros show how to use Survival macro commands for AUTOMATED ANALYSIS   
  2. The possibilities are only limited by your imagination. Remember that you   
  3. may use all Pascal standard functions within a macro. Probably you may need
  4. some book on elemental Pascal programming to take the maximun advantage}  
  5.  
  6. MACRO 'TimeDependent';
  7.  
  8. {This macro is to be used with Time-Dependent Analysis
  9. It must be the only macro or the FIRST macro in a multiple
  10. macro file. You may edit the code to adapt it to your needs.
  11. See also TIME MACRO 1 in the Macros folder}
  12.  
  13. begin
  14.  
  15.     FUNCTION
  16.          If rData[2] >= 650 then rVar[1]:= (rVar[1] - rMean[1]) else rVar[1]:= 0;
  17.             rVar[2]:= (rVar[2] - rMean[2]); {Fixed covariate = grade}
  18.   end;
  19. end;
  20.  
  21.  
  22.  
  23. MACRO 'Macro_Time-Dependent_Analysis'
  24.  
  25. begin
  26.  
  27.     RESET;
  28.     GETDATA('HD516:Survival 6.0:Data:Data.surv');
  29.     setStatus(1);
  30.     setTime(2);
  31.     selectVar(3,4);
  32.  varcode(2,1);{Var 3 is time-dependent; var 4 is fixed}
  33.  varLabel(3:'edad';4:'grado');
  34.     covariates(80.5, 4);{we use this covariate pattern to estimate probability of survival}
  35.     survplot('CoxModel');{Save the Model Plot}
  36.  title('PROSTATE CANCER:TEN YEAR SURVIVAL ANALYSIS');
  37.     backColor('white');
  38.     estimate;{Time dependent analysis is TERMINATED here. Other commands are ignored}
  39. end;
  40.  
  41. MACRO 'Kaplan-Meier'
  42.  
  43. begin
  44.  
  45.     reset;
  46.     getdata('Put here the path to access the file');
  47.  stat(-);{compute descriptive statistics for all variables in data array}
  48.     setStatus(1);
  49.     setTime(2);
  50.     survplot;{use always before the ESTIMATE command}
  51.     backColor('white');
  52.     setOutput('none');
  53.     estimate;
  54.  savepict('HD516:MyTest');{saves survival function}
  55.  intplot(1);{use always AFTER the estimate command}
  56.  savepict('HD516:Intervals');
  57. end;
  58.  
  59.  
  60. MACRO 'Macro_Strata'
  61.  
  62. begin
  63.  
  64.     reset;
  65.     getdata('Put here the path to access the file');
  66.     setStatus(1);
  67.     setTime(2);
  68.  selectvar(4);
  69.     setStrata(3, 5);{we have coded 3 groups in variable 5}
  70.  grouplabel(1:'Stage A-B';2:'Stage C';3:'Stage D');{put label to indentify the groups}
  71.     survplot;
  72.     backColor('white');
  73.     setOutput('none');
  74.     estimate;
  75.  savepict('strata');
  76.  logplot;
  77.  savepict('Log-Log');
  78. end;
  79.  
  80.  
  81. MACRO 'Macro_Test_1'{observe the result}
  82. var
  83.     i: integer;
  84.  
  85. begin
  86.     reset;
  87.     getdata('Put here the path to access the file');
  88.     setStatus(1);
  89.     setTime(2);
  90.     survplot;
  91.     setOutput('none');
  92.     for i := 3 to 5 do
  93.         begin
  94.             selectVar(i);
  95.             estimate;
  96.   savepict('Test1');
  97.   resplot;
  98.   savepict('Residual1');{save residual plots and close}
  99.         end;
  100.  clear;{clears the active output window}
  101.  RUNMACRO(3); {executes the Macro_Strata macro}
  102.  RUNMACRO(7); {executes the Cut_Point macro}
  103. end;
  104.  
  105. MACRO 'Macro_Test_2'{what is the difference respect to the macro above?}
  106. var
  107.     i, row, column, nvar: integer;
  108.  
  109. begin
  110.     setStatus(1);
  111.     setTime(2);
  112.  
  113. reset;
  114.     {getdata('Put here the path to access the file');}
  115.     get(row, column, nvar);
  116.     setStatus(1);
  117.     setTime(2);
  118.     survplot;
  119.     setOutput('none');
  120.     for i := 3 to 5 do
  121.         begin
  122.             set(row,column,0);{here is the key}
  123.             selectVar(i);
  124.             estimate;
  125.         end;
  126. end;
  127.  
  128. MACRO 'Macro_CutPoint'
  129.  
  130. begin
  131.  
  132.     reset;
  133.     {getdata('Put here the path to access the file');}
  134.     setStatus(1);
  135.     setTime(2);
  136.     setCutPoint(70.5, 3);{cut point value (70.5) for variable in column 3}
  137.     survplot;
  138.     backColor('white');
  139.     setOutput('basal');
  140.     estimate;
  141.  savepict('CutPoint');
  142. end;
  143.  
  144. macro 'Macro_MakeBins'
  145.  
  146. begin
  147.  
  148.     reset;
  149.     getdata('Put here the path to access the file');
  150.     setStatus(1);
  151.     setTime(2);
  152.     MakeBins(3, 3, true, 60, 70, 80);{we recode var 3 into 4 categories}
  153.     setStrata(4,3);{stratified analysis}
  154.  grouplabel(1:'<60 YEARS';2:'60-69 YEARS';3:'70-79 YEARS'; 4:'=>80 YEARS');{put label to  
  155.  indentify the groups}
  156.  title('PROSTATE CANCER:STRATIFIED ANALYSIS BY AGE GROUPS');
  157.     survplot;
  158.     backColor('black');
  159.     estimate;
  160.  savepict('MakeBins');
  161.  logplot;
  162.  savepict('MakeBinsLog');
  163.  revert; {Restores original data}
  164. end;
  165.  
  166. MACRO 'Macro_Select'
  167.  
  168. var
  169. edad,status,grado,stage:integer
  170.  
  171. begin
  172.     RESET;
  173.     GETDATA('Put here the path to acces the file');
  174.     SETSTATUS(1);
  175.     SETTIME(2);
  176.     SELECTIF((rData[4] = 2) and (rData[5] = 3));
  177. ESTIMATE;
  178. end;
  179.  
  180. MACRO 'Macro_Omit_Compute'
  181.  
  182. var
  183. status,time,grade:integer;
  184.  
  185. begin
  186.     reset;
  187.     getdata('Put here the path to access the file');
  188.     setStatus(1);
  189.     setTime(2);
  190.     OMITIF((rData[1] = 1) and (rData[2] < 180));
  191.  COMPUTE
  192.       rData[2] := rData[2] - 180;{what would happen if you omit this command ?}
  193.     end;
  194.     SELECTIF(rData[2] > 0);{just in case}
  195.     backColor('white');
  196.     estimate;
  197. end;
  198.  
  199. MACRO 'Macro_Recode'
  200.  
  201. var
  202. grado,stage:integer;
  203.  
  204. begin
  205.     grado:= 4;
  206.  stage:= 5;
  207.     reset;
  208.     getdata('Put here the path to access the file');
  209.     setStatus(1);
  210.     setTime(2);
  211.     recode(grado:1:2;stage:2:3:-9);
  212.     MakeBins(3, 3, true, 60, 70, 80);
  213. end;
  214.  
  215. MACRO 'Macro_Compute'
  216.  
  217. var
  218. grado,stage,time:integer;
  219.  
  220. begin
  221.  time:= 2;
  222.     grado:= 4;
  223.  stage:= 5;
  224.     reset;
  225.     GETDATA('Put here the path to access the file');
  226.     SETSTATUS(1);
  227.     SETTIME(2);
  228. beep;
  229.     COMPUTE
  230. {access to vars in data file with rDAta[]}
  231. {access to selected vars for current test with rVar[]}
  232.  if (rDATA[4] = 2) and (rDATA[2] > 350) then rDATA[5]:= 9 else rDATA[5]:= -1;
  233.     rData[6]:= -9;
  234.         end;
  235.     MAKEBINS(3, 3, true, 60, 70, 80);
  236.  SETSTRATA(4,3);
  237.     beep;
  238.  ESTIMATE;
  239. end;
  240.  
  241. MACRO 'Macro_Compute_Mean';
  242. var
  243. i,j,rows,cols,nvar,index:integer;
  244. Mean:real;
  245. begin
  246. get(rows,cols,nvar);{gets number of cases, variables and selected variables for the test, if any}
  247. for j:= 1 to cols do
  248.     begin
  249.     Mean:= 0;
  250.         for i:= 0 to rows - 1 do
  251.             begin
  252.                 index:= i * cols + j;
  253.                 Mean:= Mean + gData[index];{notice that we use gData[] instead of rData[]}
  254.                 end;
  255.     Mean:= Mean/rows;
  256.  Write('Mean of Variable ', 'with value',j,' is :',mean, ' for a total of', rows, ' variables');
  257.     end;{For j}
  258. end;
  259.  
  260. MACRO 'Macro_Compute_DS';
  261. var
  262. i,j,rows,cols,nvar,index:integer;
  263. sd,sigma1,sigma2:real;
  264. begin
  265. get(rows,cols,nvar);{gets number of cases, variables and selected variables for the test, if any}
  266. write('Standard Deviations are shown sequentially for variables 1 ..',cols);
  267. for j:= 1 to cols do
  268.     begin
  269.     sd:= 0;sigma1:= 0;sigma2:= 0;
  270.         for i:= 0 to rows - 1 do
  271.             begin
  272.                 index:= i * cols + j;
  273.                 sigma1:= Sigma1 + gData[index];
  274.                 sigma2:= sigma2 + sqr(gData[index]);
  275.    end;
  276.     sd:= sqrt((sigma2 - (sqr(sigma1)/rows))/(rows -1));
  277.  Write('S.D. :',sd);
  278.     end;{For j}
  279. end;
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.